// hyb_yl/doctorHome/pages/set_chargedata/set_chargedata.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    ids:"",
    title:"",
    state:0,
    ptmoney:"",
    ptzhuiw:"",
    hymoney:"",
    hyzhuiw:"",

  },
  switch_btn:function(e){
    console.log(e.detail.value)
    var checked=e.detail.value;
    this.setData({
      state:e.detail.value
    })
  },
  // 普通问诊价格
  ptmoney_input:function(e){
    this.setData({
      ptmoney:e.detail.value
    })
  },
  // 普通免费次数
  ptzhuiw_input:function(e){
    this.setData({
      ptzhuiw:e.detail.value
    })
  },
  // 普通问诊价格
  hymoney_input:function(e){
    this.setData({
      hymoney:e.detail.value
    })
  },
  // 普通免费次数
  hyzhuiw_input:function(e){
    this.setData({
      hyzhuiw:e.detail.value
    })
  },
  determine:function(e){
    var that = this;
    var state=that.data.state;//是否开启
    var ids = that.data.ids
    var ptmoney = that.data.ptmoney
    var ptzhuiw = that.data.ptzhuiw
    var hymoney = that.data.hymoney
    var hyzhuiw = that.data.hyzhuiw
    app.util.request({
      url: 'entry/wxapp/zhuanjia.update_detail',
      data: {
        ids: ids,
        ptmoney: ptmoney,
        ptzhuiw: ptzhuiw,
        hymoney: hymoney,
        hyzhuiw: hyzhuiw,
        state:state
      },
      success: function (res) {
        console.log(res)
        wx.showToast({
          title: '编辑成功',
          icon: 'none'
        })
        wx.navigateBack({
          complete: (res) => {},
        })
      }
    })
    wx.navigateBack({
      delta: 1,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var ids = options.ids;
    var title = options.title;
    that.setData({
      ids:ids,
      title:title,
      state:options.state
    })
    that.getDetail();
  },
  getDetail:function(){
    var that = this;
    app.util.request({
      url: 'entry/wxapp/zhuanjia.server_detail',
      data: {
        ids: that.data.ids
      },
      success: function (res) {
        that.setData({
          detail: res.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})